package com.xingchen.springboot3.utils;

import cn.hutool.core.date.LocalDateTimeUtil;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;


public class DateUtils extends LocalDateTimeUtil {

    public static LocalDateTime getDateTime() {
        return LocalDateTime.now();
    }

    public static LocalDate getDate() {
        return LocalDate.now();
    }

    public static LocalTime getTime() {
        return LocalTime.now();
    }

    public static String getDateStr(String pattern) {
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
        return LocalDate.now().format(formatter);
    }

    //获取时间 HHmmss
    public static String getTimeStr(String pattern) {
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
        return LocalTime.now().format(formatter);
    }

    public static String getDateTimeStr(String pattern) {
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
        return LocalDateTime.now().format(formatter);
    }
}
